/*
 * Generated file. 
 * 
 * Mobile_005ffileDownload.java
 */
package xsp;

import com.ibm.xsp.page.compiled.AbstractCompiledPage;
import com.ibm.xsp.page.compiled.AbstractCompiledPageDispatcher;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import com.ibm.xsp.page.compiled.NoSuchComponentException;
import com.ibm.xsp.page.compiled.PageExpressionEvaluator;
import java.lang.String;
import com.ibm.xsp.component.UIViewRootEx2;
import com.ibm.xsp.component.UIPanelEx;
import javax.faces.el.ValueBinding;
import com.ibm.xsp.component.xp.XspOutputLabel;
import com.ibm.xsp.component.xp.XspDataIterator;
import java.lang.Object;
import com.ibm.xsp.component.xp.XspOutputLink;
import com.ibm.xsp.component.xp.XspLineBreak;

@SuppressWarnings("all")
public class Mobile_005ffileDownload extends AbstractCompiledPageDispatcher{
    
    public Mobile_005ffileDownload() {
        super("3.0");
    }

    protected AbstractCompiledPage createPage(int pageIndex) {
        return new Mobile_005ffileDownloadPage();
    }
    
    protected boolean isCustomControl() {
        return true;
    }

    public static class Mobile_005ffileDownloadPage extends AbstractCompiledPage {
        
        private static final ComponentInfo[] s_infos = new ComponentInfo[]{
            ComponentInfo.EMPTY_NORMAL, // 0 "label1"
            new ComponentInfo(false, new int[]{0}), // 1 panel
            ComponentInfo.EMPTY_NORMAL, // 2 "label4"
            ComponentInfo.EMPTY_NORMAL, // 3 br
            new ComponentInfo(false, new int[]{2, 3}), // 4 "repeatlist"
            new ComponentInfo(false, new int[]{1, 4}), // 5 view
        };
        
        public Mobile_005ffileDownloadPage() {
            super(5, s_infos );
        }
        
        public int getComponentForId(String id) throws NoSuchComponentException { 
            if( "label1".equals(id) )
                return 0;
            if( "repeatlist".equals(id) )
                return 4;
            if( "label4".equals(id) )
                return 2;
            return -1;
        }
        
        public UIComponent createComponent(int id, FacesContext context,
                UIComponent parent, PageExpressionEvaluator evaluator)
                throws NoSuchComponentException { 
            switch (id) {
            case 5:
                return createView(context, parent, evaluator);
            case 1:
                return createPanel(context, parent, evaluator);
            case 0:
                return createLabel1(context, parent, evaluator);
            case 4:
                return createRepeatlist(context, parent, evaluator);
            case 2:
                return createLabel4(context, parent, evaluator);
            case 3:
                return createBr(context, parent, evaluator);
            }
            throw new NoSuchComponentException(id);
        }
        
        private UIComponent createView(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIViewRootEx2 result = new UIViewRootEx2();
            initViewRoot(result);
            return result;
        }

        private UIComponent createPanel(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIPanelEx result = new UIPanelEx();
            String sourceId = "/xp:view[1]/xp:panel[1]/xp:this.rendered[1]/text()";
            String renderedExpr = "#{javascript:\n\t\t\tvar al:java.util.List = dominoDoc.getAttachmentList(\"Body\");\n\t\t\tif(al.isEmpty())\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}";
            ValueBinding rendered = evaluator.createValueBinding(result, renderedExpr, sourceId,boolean.class);
            result.setValueBinding("rendered", rendered);
            result.setStyleClass("mblFileDownloadPanel");
            return result;
        }

        private UIComponent createLabel1(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspOutputLabel result = new XspOutputLabel();
            result.setValue("Attachments:");
            result.setStyleClass("mblFileDownloadlbl");
            result.setFor("repeatList");
            setId(result, "label1");
            return result;
        }

        private UIComponent createRepeatlist(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspDataIterator result = new XspDataIterator();
            result.setFirst(0);
            String sourceId = "repeatList/@value";
            String valueExpr = "#{javascript:dominoDoc.getAttachmentList(\'Body\')}";
            ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);
            result.setValueBinding("value", value);
            String sourceId2 = "repeatList/@rendered";
            String renderedExpr = "#{javascript:var lastlevel=0;}";
            ValueBinding rendered = evaluator.createValueBinding(result, renderedExpr, sourceId2,boolean.class);
            result.setValueBinding("rendered", rendered);
            result.setIndexVar("attachIndex");
            result.setVar("attachData");
            result.setRows(300);
            setId(result, "repeatList");
            return result;
        }

        private UIComponent createLabel4(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspOutputLink result = new XspOutputLink();
            String sourceId = "label4/xp:this.value[1]/text()";
            String valueExpr = "#{javascript:\n\t\t\t\tvar al:java.util.List = dominoDoc.getAttachmentList(\"Body\");\n\t\t\t\tvar eo:NotesEmbeddedObject = \"\";\n\t\t\t\tif(!al.isEmpty())\n\t\t\t\t{\n\t\t\t\t\teo = al.get(attachIndex);\n\t\t\t\t\treturn eo.getHref();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn \"\";\n\t\t\t\t}\n\t\t\t}";
            ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);
            result.setValueBinding("value", value);
            setId(result, "label4");
            String sourceId2 = "label4/xp:this.text[1]/text()";
            String textExpr = "#{javascript:\n\t\t\t\tvar al:java.util.List = dominoDoc.getAttachmentList(\"Body\");\n\t\t\t\tif(!al.isEmpty())\n\t\t\t\t{\n\t\t\t\t\tvar eo:NotesEmbeddedObject = al.get(attachIndex);\n\t\t\t\t\treturn eo.getName();\n\t\t\t\t}\n\t\t\t}";
            ValueBinding text = evaluator.createValueBinding(result, textExpr, sourceId2,String.class);
            result.setValueBinding("text", text);
            return result;
        }

        private UIComponent createBr(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspLineBreak result = new XspLineBreak();
            return result;
        }

    }
}
